@@ -182,95 +182,78 @@ this. For a small app like polls, this process isn't too difficult.
182
182
license. Just be aware that your licensing choice will affect who is able
183
183
to use your code.
184
184
185
- #. Next we'll create ``pyproject.toml``, ``setup.cfg``, and ``setup.py`` files
186
- which detail how to build and install the app. A full explanation of these
187
- files is beyond the scope of this tutorial, but the `setuptools
188
- documentation <https://setuptools.pypa.io/en/latest/>`_ has a good
189
- explanation. Create the ``django-polls/pyproject.toml``,
190
- ``django-polls/setup.cfg``, and ``django-polls/setup.py`` files with the
185
+ #. Next we'll create the ``pyproject.toml`` file which details how to build and
186
+ install the app. A full explanation of this file is beyond the scope of this
187
+ tutorial, but the `Python Packaging User Guide
188
+ <https://packaging.python.org/guides/writing-pyproject-toml/>`_ has a good
189
+ explanation. Create the ``django-polls/pyproject.toml`` file with the
191
190
following contents:
192
191
193
192
.. code-block:: toml
194
- :caption: ``django-polls/pyproject.toml``
195
-
196
- [build-system]
197
- requires = ['setuptools>=40.8.0']
198
- build-backend = 'setuptools.build_meta'
199
-
200
- .. code-block:: ini
201
- :caption: ``django-polls/setup.cfg``
202
-
203
- [metadata]
204
- name = django-polls
205
- version = 0.1
206
- description = A Django app to conduct web-based polls.
207
- long_description = file: README.rst
208
- url = https://www.example.com/
209
- author = Your Name
210
- author_email = yourname@example.com
211
- license = BSD-3-Clause # Example license
212
- classifiers =
213
- Environment :: Web Environment
214
- Framework :: Django
215
- Framework :: Django :: X.Y # Replace "X.Y" as appropriate
216
- Intended Audience :: Developers
217
- License :: OSI Approved :: BSD License
218
- Operating System :: OS Independent
219
- Programming Language :: Python
220
- Programming Language :: Python :: 3
221
- Programming Language :: Python :: 3 :: Only
222
- Programming Language :: Python :: 3.8
223
- Programming Language :: Python :: 3.9
224
- Programming Language :: Python :: 3.10
225
- Programming Language :: Python :: 3.11
226
- Programming Language :: Python :: 3.12
227
- Topic :: Internet :: WWW/HTTP
228
- Topic :: Internet :: WWW/HTTP :: Dynamic Content
229
-
230
- [options]
231
- include_package_data = true
232
- packages = find:
233
- python_requires = >=3.8
234
- install_requires =
235
- Django >= X.Y # Replace "X.Y" as appropriate
236
-
237
- .. code-block:: python
238
- :caption: ``django-polls/setup.py``
239
-
240
- from setuptools import setup
241
-
242
- setup()
243
-
244
- #. Only Python modules and packages are included in the package by default. To
245
- include additional files, we'll need to create a ``MANIFEST.in`` file. The
246
- ``setuptools`` docs referred to in the previous step discuss this file in
247
- more detail. To include the templates, the ``README.rst`` and our
248
- ``LICENSE`` file, create a file ``django-polls/MANIFEST.in`` with the
249
- following contents:
193
+ :caption: ``django-polls/pyproject.toml``
194
+
195
+ [build-system]
196
+ requires = ["setuptools>=61.0"]
197
+ build-backend = "setuptools.build_meta"
198
+
199
+ [project]
200
+ name = "django-polls"
201
+ version = "0.1"
202
+ dependencies = [
203
+ "django>=X.Y", # Replace "X.Y" as appropriate
204
+ ]
205
+ description = "A Django app to conduct web-based polls."
206
+ readme = "README.rst"
207
+ requires-python = ">= 3.8"
208
+ authors = [
209
+ {name = "Your Name", email = "yourname@example.com"},
210
+ ]
211
+ classifiers = [
212
+ "Environment :: Web Environment",
213
+ "Framework :: Django",
214
+ "Framework :: Django :: X.Y", # Replace "X.Y" as appropriate
215
+ "Intended Audience :: Developers",
216
+ "License :: OSI Approved :: BSD License",
217
+ "Operating System :: OS Independent",
218
+ "Programming Language :: Python",
219
+ "Programming Language :: Python :: 3",
220
+ "Programming Language :: Python :: 3 :: Only",
221
+ "Programming Language :: Python :: 3.8",
222
+ "Programming Language :: Python :: 3.9",
223
+ "Programming Language :: Python :: 3.10",
224
+ "Programming Language :: Python :: 3.11",
225
+ "Programming Language :: Python :: 3.12",
226
+ "Topic :: Internet :: WWW/HTTP",
227
+ "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
228
+ ]
229
+
230
+ [project.urls]
231
+ Homepage = "https://www.example.com/"
232
+
233
+ #. Many common files and Python modules and packages are included in the
234
+ package by default. To include additional files, we'll need to create a
235
+ ``MANIFEST.in`` file. To include the templates and static files, create a
236
+ file ``django-polls/MANIFEST.in`` with the following contents:
250
237
251
238
.. code-block:: text
252
- :caption: ``django-polls/MANIFEST.in``
239
+ :caption: ``django-polls/MANIFEST.in``
253
240
254
- include LICENSE
255
- include README.rst
256
- recursive-include polls/static *
257
- recursive-include polls/templates *
241
+ recursive-include polls/static *
242
+ recursive-include polls/templates *
258
243
259
244
#. It's optional, but recommended, to include detailed documentation with your
260
245
app. Create an empty directory ``django-polls/docs`` for future
261
- documentation. Add an additional line to ``django-polls/MANIFEST.in``:
262
-
263
- .. code-block:: text
264
-
265
- recursive-include docs *
246
+ documentation.
266
247
267
248
Note that the ``docs`` directory won't be included in your package unless
268
249
you add some files to it. Many Django apps also provide their documentation
269
250
online through sites like `readthedocs.org <https://readthedocs.org>`_.
270
251
271
- #. Try building your package with ``python setup.py sdist`` (run from inside
272
- ``django-polls``). This creates a directory called ``dist`` and builds your
273
- new package, ``django-polls-0.1.tar.gz``.
252
+ #. Check that the :pypi:`build` package is installed (``python -m pip install
253
+ build``) and try building your package by running ``python -m build`` inside
254
+ ``django-polls``. This creates a directory called ``dist`` and builds your
255
+ new package into source and binary formats, ``django-polls-0.1.tar.gz`` and
256
+ ``django_polls-0.1-py3-none-any.whl``.
274
257
275
258
For more information on packaging, see Python's `Tutorial on Packaging and
276
259
Distributing Projects
0 commit comments